﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Playables.ScriptPlayableOutput
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine.Playables
{
  /// <summary>
  ///   <para>A IPlayableOutput implementation that contains a script output for the a PlayableGraph.</para>
  /// </summary>
  [RequiredByNativeCode]
  public struct ScriptPlayableOutput : IPlayableOutput
  {
    private PlayableOutputHandle m_Handle;

    /// <summary>
    ///   <para>Creates a new ScriptPlayableOutput in the associated PlayableGraph.</para>
    /// </summary>
    /// <param name="graph">The PlayableGraph that will contain the ScriptPlayableOutput.</param>
    /// <param name="name">The name of this ScriptPlayableOutput.</param>
    /// <returns>
    ///   <para>The created ScriptPlayableOutput.</para>
    /// </returns>
    public static ScriptPlayableOutput Create(PlayableGraph graph, string name)
    {
      PlayableOutputHandle handle;
      return !graph.CreateScriptOutputInternal(name, out handle) ? ScriptPlayableOutput.Null : new ScriptPlayableOutput(handle);
    }

    internal ScriptPlayableOutput(PlayableOutputHandle handle)
    {
      this.m_Handle = !handle.IsValid() || handle.IsPlayableOutputOfType<ScriptPlayableOutput>() ? handle : throw new InvalidCastException("Can't set handle: the playable is not a ScriptPlayableOutput.");
    }

    /// <summary>
    ///   <para>Returns an invalid ScriptPlayableOutput.</para>
    /// </summary>
    public static ScriptPlayableOutput Null => new ScriptPlayableOutput(PlayableOutputHandle.Null);

    public PlayableOutputHandle GetHandle() => this.m_Handle;

    public static implicit operator PlayableOutput(ScriptPlayableOutput output)
    {
      return new PlayableOutput(output.GetHandle());
    }

    public static explicit operator ScriptPlayableOutput(PlayableOutput output)
    {
      return new ScriptPlayableOutput(output.GetHandle());
    }
  }
}
